module.exports = ({ menuSchema }) => ({
  Role: {
    menus: {
      fragment: `... on Role { menuIds }`,
      resolve (role, args, context, info) {
        return info.mergeInfo.delegateToSchema({
          schema: menuSchema,
          operation: 'query',
          fieldName: 'menus',
          args: {
            where: {
              id: {
                $in: role.menuIds
              }
            },
            pagination: {
              limit: 10
            }
          },
          context,
          info
        })
      }
    }
  }
})
